<?php


abstract class BaseAntegineobs extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $numhistoria;


	
	protected $pri_mens;


	
	protected $edad_meno;


	
	protected $cant_emb;


	
	protected $fue_term;


	
	protected $parto_vag;


	
	protected $vag_cant;


	
	protected $cesa_cant;


	
	protected $complica;


	
	protected $abortos;


	
	protected $metaantic;


	
	protected $cesarias;

	
	protected $aHistoria;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNumhistoria()
	{

		return $this->numhistoria;
	}

	
	public function getPriMens()
	{

		return $this->pri_mens;
	}

	
	public function getEdadMeno()
	{

		return $this->edad_meno;
	}

	
	public function getCantEmb()
	{

		return $this->cant_emb;
	}

	
	public function getFueTerm()
	{

		return $this->fue_term;
	}

	
	public function getPartoVag()
	{

		return $this->parto_vag;
	}

	
	public function getVagCant()
	{

		return $this->vag_cant;
	}

	
	public function getCesaCant()
	{

		return $this->cesa_cant;
	}

	
	public function getComplica()
	{

		return $this->complica;
	}

	
	public function getAbortos()
	{

		return $this->abortos;
	}

	
	public function getMetaantic()
	{

		return $this->metaantic;
	}

	
	public function getCesarias()
	{

		return $this->cesarias;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = AntegineobsPeer::ID;
		}

	} 
	
	public function setNumhistoria($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->numhistoria !== $v) {
			$this->numhistoria = $v;
			$this->modifiedColumns[] = AntegineobsPeer::NUMHISTORIA;
		}

		if ($this->aHistoria !== null && $this->aHistoria->getNumhistoria() !== $v) {
			$this->aHistoria = null;
		}

	} 
	
	public function setPriMens($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->pri_mens !== $v) {
			$this->pri_mens = $v;
			$this->modifiedColumns[] = AntegineobsPeer::PRI_MENS;
		}

	} 
	
	public function setEdadMeno($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->edad_meno !== $v) {
			$this->edad_meno = $v;
			$this->modifiedColumns[] = AntegineobsPeer::EDAD_MENO;
		}

	} 
	
	public function setCantEmb($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->cant_emb !== $v) {
			$this->cant_emb = $v;
			$this->modifiedColumns[] = AntegineobsPeer::CANT_EMB;
		}

	} 
	
	public function setFueTerm($v)
	{

		if ($this->fue_term !== $v) {
			$this->fue_term = $v;
			$this->modifiedColumns[] = AntegineobsPeer::FUE_TERM;
		}

	} 
	
	public function setPartoVag($v)
	{

		if ($this->parto_vag !== $v) {
			$this->parto_vag = $v;
			$this->modifiedColumns[] = AntegineobsPeer::PARTO_VAG;
		}

	} 
	
	public function setVagCant($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->vag_cant !== $v) {
			$this->vag_cant = $v;
			$this->modifiedColumns[] = AntegineobsPeer::VAG_CANT;
		}

	} 
	
	public function setCesaCant($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->cesa_cant !== $v) {
			$this->cesa_cant = $v;
			$this->modifiedColumns[] = AntegineobsPeer::CESA_CANT;
		}

	} 
	
	public function setComplica($v)
	{

		if ($this->complica !== $v) {
			$this->complica = $v;
			$this->modifiedColumns[] = AntegineobsPeer::COMPLICA;
		}

	} 
	
	public function setAbortos($v)
	{

		if ($this->abortos !== $v) {
			$this->abortos = $v;
			$this->modifiedColumns[] = AntegineobsPeer::ABORTOS;
		}

	} 
	
	public function setMetaantic($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->metaantic !== $v) {
			$this->metaantic = $v;
			$this->modifiedColumns[] = AntegineobsPeer::METAANTIC;
		}

	} 
	
	public function setCesarias($v)
	{

		if ($this->cesarias !== $v) {
			$this->cesarias = $v;
			$this->modifiedColumns[] = AntegineobsPeer::CESARIAS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->numhistoria = $rs->getInt($startcol + 1);

			$this->pri_mens = $rs->getInt($startcol + 2);

			$this->edad_meno = $rs->getInt($startcol + 3);

			$this->cant_emb = $rs->getInt($startcol + 4);

			$this->fue_term = $rs->getBoolean($startcol + 5);

			$this->parto_vag = $rs->getBoolean($startcol + 6);

			$this->vag_cant = $rs->getInt($startcol + 7);

			$this->cesa_cant = $rs->getInt($startcol + 8);

			$this->complica = $rs->getBoolean($startcol + 9);

			$this->abortos = $rs->getBoolean($startcol + 10);

			$this->metaantic = $rs->getString($startcol + 11);

			$this->cesarias = $rs->getBoolean($startcol + 12);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 13; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Antegineobs object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(AntegineobsPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			AntegineobsPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(AntegineobsPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aHistoria !== null) {
				if ($this->aHistoria->isModified()) {
					$affectedRows += $this->aHistoria->save($con);
				}
				$this->setHistoria($this->aHistoria);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = AntegineobsPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += AntegineobsPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aHistoria !== null) {
				if (!$this->aHistoria->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aHistoria->getValidationFailures());
				}
			}


			if (($retval = AntegineobsPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = AntegineobsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNumhistoria();
				break;
			case 2:
				return $this->getPriMens();
				break;
			case 3:
				return $this->getEdadMeno();
				break;
			case 4:
				return $this->getCantEmb();
				break;
			case 5:
				return $this->getFueTerm();
				break;
			case 6:
				return $this->getPartoVag();
				break;
			case 7:
				return $this->getVagCant();
				break;
			case 8:
				return $this->getCesaCant();
				break;
			case 9:
				return $this->getComplica();
				break;
			case 10:
				return $this->getAbortos();
				break;
			case 11:
				return $this->getMetaantic();
				break;
			case 12:
				return $this->getCesarias();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = AntegineobsPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNumhistoria(),
			$keys[2] => $this->getPriMens(),
			$keys[3] => $this->getEdadMeno(),
			$keys[4] => $this->getCantEmb(),
			$keys[5] => $this->getFueTerm(),
			$keys[6] => $this->getPartoVag(),
			$keys[7] => $this->getVagCant(),
			$keys[8] => $this->getCesaCant(),
			$keys[9] => $this->getComplica(),
			$keys[10] => $this->getAbortos(),
			$keys[11] => $this->getMetaantic(),
			$keys[12] => $this->getCesarias(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = AntegineobsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNumhistoria($value);
				break;
			case 2:
				$this->setPriMens($value);
				break;
			case 3:
				$this->setEdadMeno($value);
				break;
			case 4:
				$this->setCantEmb($value);
				break;
			case 5:
				$this->setFueTerm($value);
				break;
			case 6:
				$this->setPartoVag($value);
				break;
			case 7:
				$this->setVagCant($value);
				break;
			case 8:
				$this->setCesaCant($value);
				break;
			case 9:
				$this->setComplica($value);
				break;
			case 10:
				$this->setAbortos($value);
				break;
			case 11:
				$this->setMetaantic($value);
				break;
			case 12:
				$this->setCesarias($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = AntegineobsPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNumhistoria($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPriMens($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setEdadMeno($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCantEmb($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setFueTerm($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setPartoVag($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setVagCant($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCesaCant($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setComplica($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setAbortos($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setMetaantic($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setCesarias($arr[$keys[12]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(AntegineobsPeer::DATABASE_NAME);

		if ($this->isColumnModified(AntegineobsPeer::ID)) $criteria->add(AntegineobsPeer::ID, $this->id);
		if ($this->isColumnModified(AntegineobsPeer::NUMHISTORIA)) $criteria->add(AntegineobsPeer::NUMHISTORIA, $this->numhistoria);
		if ($this->isColumnModified(AntegineobsPeer::PRI_MENS)) $criteria->add(AntegineobsPeer::PRI_MENS, $this->pri_mens);
		if ($this->isColumnModified(AntegineobsPeer::EDAD_MENO)) $criteria->add(AntegineobsPeer::EDAD_MENO, $this->edad_meno);
		if ($this->isColumnModified(AntegineobsPeer::CANT_EMB)) $criteria->add(AntegineobsPeer::CANT_EMB, $this->cant_emb);
		if ($this->isColumnModified(AntegineobsPeer::FUE_TERM)) $criteria->add(AntegineobsPeer::FUE_TERM, $this->fue_term);
		if ($this->isColumnModified(AntegineobsPeer::PARTO_VAG)) $criteria->add(AntegineobsPeer::PARTO_VAG, $this->parto_vag);
		if ($this->isColumnModified(AntegineobsPeer::VAG_CANT)) $criteria->add(AntegineobsPeer::VAG_CANT, $this->vag_cant);
		if ($this->isColumnModified(AntegineobsPeer::CESA_CANT)) $criteria->add(AntegineobsPeer::CESA_CANT, $this->cesa_cant);
		if ($this->isColumnModified(AntegineobsPeer::COMPLICA)) $criteria->add(AntegineobsPeer::COMPLICA, $this->complica);
		if ($this->isColumnModified(AntegineobsPeer::ABORTOS)) $criteria->add(AntegineobsPeer::ABORTOS, $this->abortos);
		if ($this->isColumnModified(AntegineobsPeer::METAANTIC)) $criteria->add(AntegineobsPeer::METAANTIC, $this->metaantic);
		if ($this->isColumnModified(AntegineobsPeer::CESARIAS)) $criteria->add(AntegineobsPeer::CESARIAS, $this->cesarias);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(AntegineobsPeer::DATABASE_NAME);

		$criteria->add(AntegineobsPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNumhistoria($this->numhistoria);

		$copyObj->setPriMens($this->pri_mens);

		$copyObj->setEdadMeno($this->edad_meno);

		$copyObj->setCantEmb($this->cant_emb);

		$copyObj->setFueTerm($this->fue_term);

		$copyObj->setPartoVag($this->parto_vag);

		$copyObj->setVagCant($this->vag_cant);

		$copyObj->setCesaCant($this->cesa_cant);

		$copyObj->setComplica($this->complica);

		$copyObj->setAbortos($this->abortos);

		$copyObj->setMetaantic($this->metaantic);

		$copyObj->setCesarias($this->cesarias);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new AntegineobsPeer();
		}
		return self::$peer;
	}

	
	public function setHistoria($v)
	{


		if ($v === null) {
			$this->setNumhistoria(NULL);
		} else {
			$this->setNumhistoria($v->getNumhistoria());
		}


		$this->aHistoria = $v;
	}


	
	public function getHistoria($con = null)
	{
		if ($this->aHistoria === null && ($this->numhistoria !== null)) {
						$this->aHistoria = HistoriaPeer::retrieveByPK($this->numhistoria, $con);

			
		}
		return $this->aHistoria;
	}

} 